package com.yl.auth.controller;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yl.auth.entity.Shenpiliu;
import com.yl.auth.entity.Shenpishezhi;
import com.yl.auth.model.entity.Yuangong;
import com.yl.auth.model.vo.YuangongQueryVo;
import com.yl.auth.service.ShenpiliuService;
import com.yl.auth.service.ShenpishezhiService;
import com.yl.auth.service.YuangongService;
import com.yl.common.result.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.ibatis.annotations.Delete;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author ln
 * @since 2023-07-03
 */
@Api(tags = "基础设置-审批设置")
@RestController
@RequestMapping("/admin/auth/shenpishezhi")
public class ShenpishezhiController {
    @Resource
    private ShenpishezhiService shenpishezhiService;
    @Resource
    private ShenpiliuService shenpiliuService;
    @Resource
    private YuangongService yuangongService;
      @ApiOperation(value = "查询全部信息")
      @GetMapping("/findAll/{page}/{limit}")
    public Result<IPage> findAll(@PathVariable Integer page,@PathVariable Integer limit){
        Page<Shenpishezhi> page1 = new Page<>(page, limit);
        IPage<Shenpishezhi> shenpishezhiList = shenpishezhiService.findAll(page1);
        return Result.ok(shenpishezhiList);
    }
//    @ApiOperation(value = "根据id查询对应的审批配置")
//    @GetMapping("/getById/{id}")
//    public Result getById(@PathVariable Integer id){
//        Shenpishezhi byId = shenpishezhiService.getById(id);
//        return Result.ok(byId);
//    }
//    @ApiOperation(value = "配置审批流")
//    @GetMapping("/findshenpi/{page}/{limit}")
//    public Result findshenpi(@PathVariable Integer page,@PathVariable Integer limit){
//        Page<Shenpiliu> page2 = new Page<>(page, limit);
//        IPage<Shenpiliu> shenpiliuList = shenpiliuService.listshenpi(page2);
//        return Result.ok(shenpiliuList);
//    }
//    @ApiOperation(value = "查询所有的员工")
//    @GetMapping("/getYuangong")
//    public Result getYuangong(YuangongQueryVo yuangong){
//        System.out.println("========================"+yuangong);
//          List<Yuangong> yuangongList=yuangongService.getYuangong(yuangong);
//          return Result.ok(yuangongList);
//    }
//    @ApiOperation(value = "根据id删除审批人")
//    @DeleteMapping("/romove/{id}")
//    public Result romove(@PathVariable Integer id){
//          shenpiliuService.removeById(id);
//          return Result.ok();
//    }
//    @ApiOperation(value = "添加审批人")
//    @PostMapping("/save")
//    public Result save(@RequestBody List<Long> ids){
//        for (Long id : ids) {
//            Yuangong byId = yuangongService.getById(id);
//            Shenpiliu shenpiliu=new Shenpiliu();
//            shenpiliu.setYuangongId(byId.getId());
//            shenpiliu.setToxiang(byId.getAvatar());
//            shenpiliu.setName(byId.getName());
//            shenpiliu.setPhone(byId.getPhone());
//            shenpiliuService.save(shenpiliu);
//        }
//        return Result.ok();
//    }
//
    @ApiOperation(value = "查询列表全部信息不加分页")
    @GetMapping("/findAll")
    public Result findAll(){
        List<Shenpiliu> list = shenpiliuService.list();
        return Result.ok(list);
    }
}

